using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;

namespace LabMS.Web.CommonPage
{
    public partial class CourseOutLine : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack) 
            {
                DataBinds();
            }

        }
        protected void DataBinds() 
        {
            Gv_DataBind();
        }
        protected void Gv_DataBind() 
        {
            LabMS.BLL.Course Course = new LabMS.BLL.Course();
            List<LabMS.Model.Course> ls = new List<LabMS.Model.Course>();

            ls = Course.GetModelList(CombineStr());
            if (ls.Count != 0) 
            {
                Gv_OutLine.DataSource = ls;
                Gv_OutLine.DataBind();
            }
        }
        protected string CombineStr() 
        {
            string strWhere = "";
            if (ddl_SearchType.SelectedValue == "0" && !string.IsNullOrEmpty(tb_KeyWord.Text))
            {
                strWhere += " Course_Code='" + tb_KeyWord.Text.Trim() + "'";

            }
            else if(ddl_SearchType.SelectedValue=="1" && !string.IsNullOrEmpty(tb_KeyWord.Text))
            {
                strWhere += " Course_Name='" + tb_KeyWord.Text.Trim() + "'";
            }
            return strWhere;
        }

        protected void Gv_OutLine_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow) 
            {
                //e.Row.Attributes.Add("onmouseover","this.style.backgroundColor='#E6f5fa'");
                //e.Row.Attributes.Add("onmouseout","this.style.backgroundColor='#FFFFFF'");
                e.Row.Attributes["style"] = "Cursor:pointer";
                e.Row.Attributes.Add("OnDblClick", "DbClickEvent('" + e.Row.Cells[0].Text + "','" + e.Row.Cells[1].Text + "','" + Gv_OutLine.DataKeys[e.Row.RowIndex].Value.ToString() + "')");
               
            }
           
            
            
        }

        protected void Gv_OutLine_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            Gv_OutLine.PageIndex = e.NewPageIndex;
            Gv_DataBind();
        }
    }
}
